#include "Scene\Material.h"

Material::Material()
	: m_opacity(1.0f),
	  m_shininess(1.0f),
	  m_ambient_factor(0.0f, 0.0f, 0.0f),
	  m_diffuse_factor(0.0f, 0.0f, 0.0f),
	  m_specular_factor(0.0f, 0.0f, 0.0f)
{
}

Material::~Material()
{
}

BOOL Material::build(aiMaterial* material)
{
	aiColor3D l_aiColor3D;

	if(AI_SUCCESS != material->Get(AI_MATKEY_OPACITY, m_opacity))
	{
		return FALSE;
	}

	if(AI_SUCCESS == material->Get(AI_MATKEY_COLOR_AMBIENT,l_aiColor3D))
	{
		m_ambient_factor = RGBColor(l_aiColor3D.r,l_aiColor3D.g,l_aiColor3D.b);
	}
	else
	{
		return FALSE;
	}

	if(AI_SUCCESS == material->Get(AI_MATKEY_COLOR_DIFFUSE,l_aiColor3D))
	{
		m_diffuse_factor = RGBColor(l_aiColor3D.r,l_aiColor3D.g,l_aiColor3D.b);
	}
	else
	{
		return FALSE;
	}

	if(AI_SUCCESS == material->Get(AI_MATKEY_COLOR_SPECULAR,l_aiColor3D))
	{
		m_specular_factor = RGBColor(l_aiColor3D.r,l_aiColor3D.g,l_aiColor3D.b);
	}
	else
	{
		return FALSE;
	}

	return TRUE;
}

FLOAT Material::GetOpacity() CONST
{
	return m_opacity;
}

FLOAT Material::GetShininess() CONST
{
	return m_shininess;
}

RGBColor Material::GetAmbient() CONST
{
	return m_ambient_factor;
}

RGBColor Material::GetDiffuse() CONST
{
	return m_diffuse_factor;
}

RGBColor Material::GetSpecular() CONST
{
	return m_specular_factor;
}